package com.andnnl.queue;

import java.util.Random;
import java.util.concurrent.PriorityBlockingQueue;

public class PriorityBlockingQueueTest {
    public static void main(String args[]) {
        PriorityBlockingQueue<People> queue = new PriorityBlockingQueue<>(100,
                (p1, p2) -> p2.age - p1.age);

        long t1 = System.currentTimeMillis();
        for (int i = 1; i <= 1000000; i++) {
            queue.add(new People("张" + i, (new Random().nextInt(10))));
        }
        while (!queue.isEmpty()) {
            queue.poll();
//            System.out.println(queue.poll().toString());
        }
        long t2 = System.currentTimeMillis();
        System.out.println(t2 - t1);
    }

}